# -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 16:41:00 2020

@author: wangshuo
"""

import matplotlib.pyplot as plt
import numpy as np
from  math import *

plt.axis([-10,150,100,-10])
plt.axis('on')
plt.grid(True)


p0=np.mat([0,0]).T
p1=np.mat([60,0]).T
p2=np.mat([60,60]).T

p_x=[p0[0,0],p1[0,0],p2[0,0],p0[0,0]]
p_y=[p0[1,0],p1[1,0],p2[1,0],p0[1,0]]
plt.plot(p_x,p_y,color='g')


#旋转变换

theta=-pi/6;#旋转角度
t_rotate=np.mat([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]])

#点乘
p0_rotate=np.dot(t_rotate,p0)
p1_rotate=np.dot(t_rotate,p1)
p2_rotate=np.dot(t_rotate,p2)

p_x_rotate=[p0_rotate[0,0],p1_rotate[0,0],p2_rotate[0,0],p0_rotate[0,0]]
p_y_rotate=[p0_rotate[1,0],p1_rotate[1,0],p2_rotate[1,0],p0_rotate[1,0]]

plt.plot(p_x_rotate,p_y_rotate,color='r')


#缩放变换
s_x=0.8
s_y=0.8
t_scale=np.mat([[s_x,0],[0,s_y]])

p0_scale=np.dot(t_scale,p0)
p1_scale=np.dot(t_scale,p1)
p2_scale=np.dot(t_scale,p2)

p_x_scale=[p0_scale[0,0],p1_scale[0,0],p2_scale[0,0],p0_scale[0,0]]
p_y_scale=[p0_scale[1,0],p1_scale[1,0],p2_scale[1,0],p0_scale[1,0]]

plt.plot(p_x_scale,p_y_scale,color='b')

plt.show()





